<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .triangle {
        --size: 24px;
        position: relative;
        width: 0;
        height: 0;
        border-top: var(--size) solid transparent;
        border-right: var(--size) solid #000;
        border-bottom: var(--size) solid transparent;
        border-left: var(--size) solid transparent;
      }
      .triangle::after {
        --size: 20px;
        display: block;
        content: "";
        position: absolute;
        top: 50%;
        /* 外层的大盒子减去 内层小盒子的宽度，然后取一半就是三角形中心 */
        left: calc(50% + 2px);
        transform: translate(-50%, -50%);
        width: 0;
        height: 0;
        border-top: var(--size) solid transparent;
        border-right: var(--size) solid #fff;
        border-bottom: var(--size) solid transparent;
        border-left: var(--size) solid transparent;
      }
    </style>
  </head>
  <body>
    <div class="triangle"></div>
  </body>
</html>
